﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace STRobot
{
    public partial class PetAddWnd : Form
    {
        public PetAddWnd()
        {
            InitializeComponent();
            index_ = -1;
        }
        public int index_;
        public PetAddWnd(int index)
        {
            InitializeComponent();
            index_ = index;
            pet = Config.Get().petinfo[index_];
            textBox2.Text = pet.name;
            textBox1.Text = pet.tid.ToString();
            checkBox1.Checked = pet.enable == 1;
        }
        //添加召唤步骤
        private void button2_Click(object sender, EventArgs e)
        {
            var uiclick = new UiClickAddWnd(pet.call);
            uiclick.ShowDialog();
            pet.call = uiclick.GetUiclicks();
        }
        Petinfo pet;

        //保存关闭窗口
        private void button1_Click(object sender, EventArgs e)
        {
            pet.name = textBox2.Text;
            pet.tid = textBox1.Text.Length > 0 ? Convert.ToInt32(textBox1.Text) : 0;
            pet.enable = checkBox1.Checked ? 1 : 0;
            DialogResult = DialogResult.OK;
            Close();
        }

        //返回结果
        public Petinfo GetPetinfo()
        {
            return pet;
        }
    }
}
